"use strict";
cc._RF.push(module, '29b43k6PjpOiKG9fB6r4YDX', 'UISign');
// script/ui/UISign.ts

"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var Constants_1 = require("../libs/Constants");
var GameData_1 = require("../libs/GameData");
var HelperMgr_1 = require("../libs/HelperMgr");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var UISign = /** @class */ (function (_super) {
    __extends(UISign, _super);
    function UISign() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.signs = null;
        return _this;
    }
    UISign.prototype.start = function () {
        this.refreshSignList();
    };
    UISign.prototype.refreshSignList = function () {
        this.node.getChildByName("Sign").active = !GameData_1.default.instance.isSignedToday;
        //签到了几天
        var signedDays = GameData_1.default.instance.signDays.length;
        for (var i = 1; i <= this.signs.childrenCount; i++) {
            var cell = this.signs.getChildByName("sign" + i);
            var signed = cell.getChildByName('signed');
            signed.active = signedDays >= i;
            var num = cell.getChildByName("num").getComponent(cc.Label);
            num.string = "X" + Constants_1.default.SignReward[i - 1];
            var select = cell.getChildByName("select");
            if (signedDays > 0) {
                if (GameData_1.default.instance.isSignedToday) {
                    select.active = i == signedDays;
                }
                else {
                    select.active = i == signedDays + 1;
                }
            }
            else {
                select.active = i == 1;
            }
        }
    };
    UISign.prototype.onSign = function () {
        this.signSuccess();
    };
    UISign.prototype.signSuccess = function () {
        var day = (new Date()).getDate();
        GameData_1.default.instance.isSignedToday = true;
        GameData_1.default.instance.signDays.push(day);
        this.refreshSignList();
        HelperMgr_1.default.showUI(Constants_1.default.UIName.UIReward);
        this.onClose();
    };
    UISign.prototype.onClose = function () {
        GameData_1.default.instance.saveData();
        this.node.removeFromParent();
        this.node.destroy();
    };
    __decorate([
        property(cc.Node)
    ], UISign.prototype, "signs", void 0);
    UISign = __decorate([
        ccclass
    ], UISign);
    return UISign;
}(cc.Component));
exports.default = UISign;

cc._RF.pop();